package com.boomsecret.joda;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;

/**
 * Created by wangjinliang on 2018/4/11.
 */
public class JodaTimeDemo {
    public static void main(String[] args) {
        DateTime dateTime1 = new DateTime(1523428434000L);
        System.out.println(dateTime1.toString("yyyy-MM-dd hh:mm:ss"));
        System.out.println(dateTime1.plusDays(1).toString("yyyy-MM-dd hh:mm:ss"));

        DateTime dateTime2 = new DateTime(
                2000, //year
                1,    // month
                1,    // day
                13,    // hour (midnight is zero)
                0,    // minute
                0,    // second
                0     // milliseconds
        );
        System.out.println(dateTime2.toString("yyyy-MM-dd hh:mm:ss"));

        LocalDate localDate = new LocalDate(2009, 9, 6);
        System.out.println(localDate.toString("yyyy-MM-dd"));

        LocalTime localTime = new LocalTime(13, 30, 26, 0);
        System.out.println(localTime.toString("hh:mm:ss"));

        DateTime dateTime3 = new DateTime(
                2000, //year
                1,    // month
                1,    // day
                1,    // hour (midnight is zero)
                0,    // minute
                0,    // second
                0     // milliseconds
        );
        DateTime dateTime4 = new DateTime(
                2000, //year
                1,    // month
                1,    // day
                13,    // hour (midnight is zero)
                0,    // minute
                0,    // second
                0     // milliseconds
        );
        System.out.println((dateTime4.getMillis() - dateTime3.getMillis()) / 1000 / 3600);
    }
}
